//
//  SinaFooterView.m
//  oc微博
//
//  Created by 安陆与 on 16/1/23.
//  Copyright © 2016年 安陆与. All rights reserved.
//

#import "SinaFooterView.h"
// 只要添加了这个宏，就不用带mas_前缀
#define MAS_SHORTHAND
// 只要添加了这个宏，equalTo就等价于mas_equalTo
#define MAS_SHORTHAND_GLOBALS
//这个头文件一定要写在宏定义下面
#import "Masonry.h"

@interface  SinaFooterView()

@property (nonatomic, weak) UIButton *retweetBtn;

@property (nonatomic, weak) UIButton *commentBtn;

@property (nonatomic, weak) UIButton *goodBtn;

@end


@implementation SinaFooterView


-(void)setFooterModel:(SinaStatusViewModel *)footerModel{

    _footerModel = footerModel;
    
    [_commentBtn setTitle:footerModel.comments_string forState:(UIControlStateNormal)];
    [_retweetBtn setTitle:footerModel.reposts_string forState:(UIControlStateNormal)];
    [_goodBtn setTitle:footerModel.attitudes_string forState:(UIControlStateNormal)];
    

}

-(instancetype)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {
        
//        self.userInteractionEnabled = YES;
        
        [self setupUI];
    }
    
    return self;
    
}


-(void)setupUI{

    //初始化按钮 转发
    UIButton *retweetBtn = [[UIButton alloc]init];
    
    self.retweetBtn = retweetBtn;
    
    [retweetBtn setImage:[UIImage imageNamed:@"timeline_icon_retweet"] forState:(UIControlStateNormal)];
    
    [retweetBtn setTitle:@"转发" forState:(UIControlStateNormal)];

    [retweetBtn setTitleColor:[UIColor darkGrayColor] forState:(UIControlStateNormal)];
    
    retweetBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    
    
    //评论按钮
    UIButton *commentBtn = [[UIButton alloc]init];
    
    self.commentBtn = commentBtn;
    
    [commentBtn setImage:[UIImage imageNamed:@"timeline_icon_comment"] forState:(UIControlStateNormal)];
    
    [commentBtn setTitleColor:[UIColor darkGrayColor] forState:(UIControlStateNormal)];
    
    commentBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    
    [commentBtn setTitle:@"评论" forState:(UIControlStateNormal)];
    
    //点赞按钮
    UIButton *googBtn = [[UIButton alloc]init];
    
    self.goodBtn = googBtn;
    
    [googBtn setImage:[UIImage imageNamed:@"timeline_icon_like"] forState:(UIControlStateNormal)];
    
    [googBtn setTitle:@"赞" forState:(UIControlStateNormal)];
//    [googBtn setTitle:@"不赞" forState:(UIControlStateHighlighted)];
    
    [googBtn setTitleColor:[UIColor darkGrayColor] forState:(UIControlStateNormal)];
    
    googBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    
    [self addSubview:retweetBtn];
    
    [self addSubview:commentBtn];
    
    [self addSubview:googBtn];
    
    //添加约束
    
    [retweetBtn makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.top);
        make.left.equalTo(self.left);
        make.bottom.equalTo(self.bottom);
        make.width.equalTo(self.commentBtn.width);
    }];
    
    [googBtn makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.top);
        make.bottom.equalTo(self.bottom);
        make.right.equalTo(self.right);
        make.width.equalTo(self.commentBtn.width);
    }];
    
    [commentBtn makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.top);
        make.bottom.equalTo(self.bottom);
        make.right.equalTo(self.goodBtn.left);
        make.left.equalTo(self.retweetBtn.right);
    }];
}


@end












